#include <ctime>
#include <cassert>
#include <iostream>
#include <cstring>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <pthread.h>

using namespace std;

void Usage(const std::string &proc)
{
    std::cout << "\r\n Usage: " << proc << " Serverip Serverport" << std::endl;
}

int main(int argc, char *argv[])
{
    // ./ClientCal Serverip Serverport
    if (argc != 3)
    {
        Usage(argv[0]);
        exit(0);
    }

    uint16_t Serverport = std::stoi(argv[2]);
    std::string Serverip = argv[1];
    int _sockfd = socket(AF_INET, SOCK_STREAM, 0);

    // 告诉客户端你连接的那台主机
    struct sockaddr_in Server;
    Server.sin_family = AF_INET;
    Server.sin_port = htons(Serverport);
    inet_pton(AF_INET, Serverip.c_str(), &(Server.sin_addr));
    socklen_t len = sizeof(Server);
    int n = connect(_sockfd, (sockaddr *)&Server, len);
    if (n < 0)
    {
        cout << "connect fail..." << endl;
    }

    // 同一类型
    while (true)
    {
        sleep(1);
    }
}